package cn.ococci.dm.Main.Adapter.Base;

import android.content.Context;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by cyan on 15/9/23.
 * 新增了局部数据的监听
 */
public abstract class AbObservableAdapter<T> extends AbBaseAdapter<T, BaseViewHolder> {

    public AbObservableAdapter(Context c, int layoutResId) {
        super(c, layoutResId);
    }

    public AbObservableAdapter(Context context, ArrayList<T> data, IMultiItemType<T> multiItemSupport) {
        super(context, data, multiItemSupport);
    }

    public AbObservableAdapter(Context c, int layoutResId, List<T> data) {
        super(c, layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, T t,int pos) {
        boolean notifyChange = holder.getRelationsObject() == null || !holder.getRelationsObject().equals(t);
        holder.setRelationsObject(t);
        convert(holder, t, notifyChange);
    }

    protected  abstract void convert(BaseViewHolder holder, T t, boolean notifyChange);
}
